import java.util.Scanner;

public class Main1469 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int a=0;
        for(int i=1;i<=n;i++){
            int x=i;
            while (x!=0){
                if (x%10==m){
                    a++;
                }x=x/10;
            }
        }
        System.out.println(a);

    }
}
